
package com.chuangan.releasetask.Utils;

import com.chuangan.releasetask.pojo.User;

import java.math.BigDecimal;

/**
 * @Author: zihua
 * @Date: 2020/6/7 23:55
 * @Version 1.0
 */
public class MathUtil {

    private static final Double MONEY_RANGE = 0.01;

    /**
     * 比较2个金额是否相等
     * @param d1
     * @param d2
     * @return
     */
    public static Boolean equals(Double d1, Double d2) {
        Double result = Math.abs(d1 - d2);
        if (result < MONEY_RANGE) {
            return true;
        }else {
            return false;
        }
    }

    public static void main(String[] args) {

        User user = new User();
        user.setUserBalance(new BigDecimal("1").add(new BigDecimal("3")));
        System.out.println(user.getUserBalance());

    }
}
